<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <link rel="stylesheet" href="css/public.css"/>
    <link rel="stylesheet" href="css/style.css"/>
    <style>
        .turn{
            width: 90px;
        }
    </style>
</head>
<body>

<section class="publicMian ">

    <div class="right">
        <div class="location">
            <strong>你现在所在的位置是:</strong>
            <span>学生管理</span>
        </div>

        <div class="search">
            <form action="studentAjax.do" method="post" id="searchform">
                <input type="hidden" name="pageIndex" id="pageIndex" value="">
                <span>学生姓名：</span>
                <input type="search" placeholder="请输入学生姓名" name="sname" value=""/>
                <input type="search" name="wechat" placeholder="微信">
                <input type="search" name="qq" placeholder="QQ">
                入学时间：<input type="date" name="dateStart" value="">--<input type="date" name="dateEnd" value="">
                <input type="submit" value="查询"/>
                <a href="addStudentServlet">添加学生</a>
            </form>
        </div>
        <!--用户-->
        <table class="providerTable" border="1" cellpadding="0" cellspacing="0">
            <tr class="firstTr">
                <th width="6%">学号</th>
                <th width="6%">姓名</th>
                <th width="6%">性别</th>
                <th width="6%">电话</th>
                <th width="6%">QQ</th>
                <th width="6%">微信</th>
                <th width="6%">年级编号</th>
                <th width="6%">年级</th>
                <th width="6%">入学日期</th>
                <th width="6%">城市</th>
                <th width="6%">出生日期</th>
                <th width="6%">住址</th>
                <th width="6%">密码</th>
                <th width="6%">身份证</th>
                <th width="10%">操作</th>
            </tr>
           <!-- <tr class="alt" >
                <td class="center" colspan="15">
                    <span id="totalA"></span>    
                   <span id="number"></span>
                    <span id="totalP"></span>
                    <span id="pageN"></span>   
                    <a href="javascript:void(0);" id="first" class="turnPage" data-page="1">首页</a> 
                        <a href="javascript:void(0);" id="prev" class="turnPage" data-page="1">上一页</a>   
                        <a href="javascript:void(0);" id="next" class="turnPage" data-page="1">下一页</a>  
                    <a href="javascript:void(0);" id="last" class="turnPage" data-page="1">最后一页</a>
                    <input type="number" name="turn" class="turn" value="1">
                    <input type="button" value="Go" name="go" id="go" onclick="turnGO()">
                </td>
            </tr>-->
        </table>
        <table cellpadding="0" cellspacing="0" align="center">
        <tr class="alt" >
            <td class="center" colspan="15">
                <span id="totalA"></span>    
                <span id="number"></span>
                <span id="totalP"></span>
                <span id="pageN"></span>   
                <a href="javascript:void(0);" id="first" class="turnPage" data-page="1">首页</a> 
                <a href="javascript:void(0);" id="prev" class="turnPage" data-page="1">上一页</a>   
                <a href="javascript:void(0);" id="next" class="turnPage" data-page="1">下一页</a>  
                <a href="javascript:void(0);" id="last" class="turnPage" data-page="1">最后一页</a>
                <input type="number" name="turn" class="turn" value="1" >
                <input type="button" value="Go" name="go" id="go" >
            </td>
        </tr>
        </table>
    </div>
</section>
<script src="js/jquery.js"></script>
<script>
    $(function () {
        var pageIndex=1;
        var sname="";
        var wechat="";
        var qq="";
        var dateStart="";
        var dateEnd="";
        function doLoad(){
            $.get("/ssm/student/ajaxsearch",{pageNo:pageIndex,sname:sname,wechat:wechat,qq:qq,dateStart:dateStart,dateEnd:dateEnd},function (studentPage) {

               //console.log(studentPage);
                var tab = $(".providerTable");
                tab.find("tr:gt(0)").remove();
                //给分页加上链接
                /*上一页*/$(".alt #prev").data("page",studentPage.pageNo<=1?1:studentPage.pageNo-1);
                /*下一页*/$(".alt #next").data("page",studentPage.pageNo<studentPage.totalPages?studentPage.pageNo+1:studentPage.totalPages);
                /*尾页*/ $(".alt #last").data("page",studentPage.totalPages);
                /*共多少条*/$(".alt #totalA").html("共"+studentPage.totalElements+"条记录");
                /*每页多少条*/$(".alt #number").html("每页"+studentPage.pageSize+"条");
                /*共多少页面*/$(".alt #totalP").html("共"+studentPage.totalPages+"页");
                /*当前第几页*/$(".alt #pageN").html("当前第"+studentPage.pageNo+"页");
                var t=1;
                if(studentPage.pageNo<0){
                    t=1;
                }else if(studentPage.pageNo>studentPage.totalPages){
                    t=studentPage.totalPages;
                }else {
                    t=pageIndex;
                }
                $(".alt .turn").val(t);
                /*sname,sex,telephone,qq,wechat,gradeid,enterdate,fromcity,birthday,address,pass,idcardpic*/
                $.each(studentPage.datas,function (i,d) {
                    var tr = $("<tr></tr>");
                    tr.append("<td>"+d.stuno+"</td>");
                    tr.append("<td>"+d.sname+"</td>");
                    tr.append("<td>"+d.sex+"</td>");
                    tr.append("<td>"+d.telephone+"</td>");
                    tr.append("<td>"+d.qq+"</td>");
                    tr.append("<td>"+d.wechat+"</td>");
                    tr.append("<td>"+d.gradeid+"</td>");
                    tr.append("<td>"+d.gname+"</td>");
                    tr.append("<td>"+d.enterdate+"</td>");
                    tr.append("<td>"+d.fromcity+"</td>");
                    tr.append("<td>"+d.birthday+"</td>");
                    tr.append("<td>"+d.address+"</td>");
                    tr.append("<td>"+d.pass+"</td>");
                    tr.append("<td>"+d.idcardpic+"</td>");
                    tr.append("<td><a href='#'>修改</a><a href='#'>删除</a></td>");
                   /* $(".firstTr").after(tr);*/
                    tab.append(tr);
                });
            },"json");
        };
        doLoad();

        $(":submit").click(function () {
            sname=$("input[name=sname]").val();
            wechat=$("input[name=wechat]").val();
            qq=$("input[name=qq]").val();
            dateStart=$("input[name=dateStart]").val();
            dateEnd=$("input[name=dateEnd]").val();
            pageIndex=1;
            doLoad();
            return false;//让提交按钮失效
        });

        $(".alt a").click(function () {
            pageIndex=$(this).data("page");/*该知识点可以查看jqueryAPI文档的核心-数据缓存*/
            doLoad();/*然后直接加载，上一页，下一页，尾页等的数据已经处理完毕*/
            return false;/*让链接失效*/
        });

        /*处理直达*/
        $("#go").click(function () {
            pageIndex=$(this).prev().val();
            doLoad();
            return false;
        })
    })
</script>
<script src="js/js.js"></script>
<script src="js/time.js"></script>

</body>
</html>